﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DBAccess;
using SSPharma.Model;
using System.Data.Common;
using SSPharma.Common;

namespace SSPharma.Biz
{
    public class BizDangNhap
    {
        static public List<NguoiSuDung> GetNguoiSDByName(string _tenNguoiSD)
        {
            List<NguoiSuDung> lsNguoiSD = new List<NguoiSuDung>();
            StringBuilder strSQL = new StringBuilder(300);
            strSQL.Append("SELECT MaNguoiSD, TenNguoiSD, MatKhau");
            strSQL.Append(" FROM HT_DM_NguoiSuDung with(nolock)");
            strSQL.Append(" WHERE MaNguoiSD = @MaNSD");

            SQLServer.Param[] Params = new SQLServer.Param[1];
            Params[0] = new SQLServer.Param("@MaNSD", _tenNguoiSD);

            using (DbDataReader dataReader = Global.DataFactory.Reader(strSQL.ToString(), Params))
            {
                if (dataReader.HasRows)
                {
                    while (dataReader.Read())
                    {
                        NguoiSuDung nsd = new NguoiSuDung();
                        nsd.MaNguoiSD = dataReader.GetString(0);
                        nsd.TenNguoiSD = dataReader.IsDBNull(1) ? string.Empty : dataReader.GetString(1);
                        nsd.MatKhau = dataReader.GetString(2);

                        lsNguoiSD.Add(nsd);
                    }
                }
            }

            return lsNguoiSD;
        }
    }
}
